package org.massdgames.thunder.server.domain.strategy;

import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;

import org.massdgames.thunder.server.domain.Card;
import org.massdgames.thunder.server.domain.CardType;
import org.massdgames.thunder.server.domain.Deck;

public class BasicFeatureLoadStrategy implements FeatureLoadStrategy {

    public Deck load(Deck deck) throws IOException {
        Properties properties = new Properties();
        properties.load(new FileInputStream("deck.properties"));
        
        int featureCount = new Integer(properties.getProperty("feature.count"));

        for (int i = 0; i < featureCount; i++) {
            Card featureCard = new Card();
            featureCard.setCardId(i);
            featureCard.setName(properties
                    .getProperty("feature." + i + ".name"));
            if (featureCard.getName().equals("Guardian")) {
                featureCard.setCardType(CardType.GUARDIAN_SELECTOR);
            } else if (featureCard.getName().trim()
                    .equalsIgnoreCase("Pick Two")) {
                featureCard.setCardType(CardType.PICK_TWO_SELECTOR);
            } else {
                featureCard.setCardType(CardType.DUNGEON_FEATURE);
            }
            deck.addCard(featureCard);
        }

        return deck;
    }

}
